home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
admin
/
linuxcon.000
/
linuxcon
/
linuxconf-1.6
/
misc
/
helpf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-12
|
1KB
|
72 lines
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "misc.h"
#include "../paths.h"
static char *lang = strdup("eng");
static HELP_FILE *first = NULL;
/*
Record the language to use for help files
*/
void help_setlang (const char *_lang)
{
free (lang);
lang = strdup(_lang);
}
/*
Record the spec of a config file that is maintain (or used) by linuxconf
*/
PUBLIC HELP_FILE::HELP_FILE(
const char *_subdir,
const char *_fname)
{
/* #Specification: help file / path
All help file of linuxconf are under the same directory
USR_LIB_CONF. Each subject (netconf, userconf, etc...) has
its own subdirectory under this directory. In these
subdirectories, we have file ending with the extension help.
*/
subdir = _subdir;
fname = _fname;
path = NULL;
next = first;
first = this;
}
/*
Return the path of the configuration file
*/
PUBLIC const char *HELP_FILE::getpath()
{
if (path == NULL && fname != NULL){
char buf[200];
sprintf (buf,"%s/help.%s/%s/%s",HELP_BASEPATH,lang,subdir,fname);
path = strdup (buf);
}
return path;
}
/*
Check if all the help file of the application are there.
This is a runtime check even if it is only requiered for testing
the software.
*/
void helpf_checkall()
{
HELP_FILE *f = first;
while (f != NULL){
const char *path = f->getpath();
if (path != NULL){
struct stat st;
printf ("%s%s\n"
,stat(path,&st)!=-1 ? "\t" : "***\t"
,path);
}
f = f->next;
}
}
HELP_FILE help_nil (NULL,NULL);